﻿/// <reference path="jquery-1.5.1.js" />

var subWin = null;
function connection(url) {
    if (subWin && !subWin.closed) {
        subWin.close();
    }
    //subWin = window.open(url, "微博连接", "location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + 600 + ", height=" + 455+",left=" + (screen.width - 600) / 2 + ",top=" + (screen.height - 455-80) / 2);
    subWin = $.openWindow(url, "微博连接", 2);
}
/**
* 改造window.open函数,保证所有窗口居中弹出,
* 并指定固定的几种窗口大小.以统一系统中的操作风格.
* url       弹出窗口路径
* tiltle    窗口标题
* size      窗口型号
*/
(function ($) {
    $.extend({
        openWindow: function (url, title, size) {
            if (!url) {
                return false;
            }
            else {
                var config = 'scrollbars=no,resizable=no,location=yes,status=no';
                var sWidth, sHeight;
                switch (size) {
                    case 1:
                        sWidth = 600;
                        sHeight = 455;
                        break;
                    case 2:
                        sWidth = 700;
                        sHeight = 550;
                        break;
                    case 3:
                        sWidth = 770;
                        sHeight = 630;
                        break;
                    default:
                        break;
                }
                if (sWidth && sHeight) {
                    var l = (screen.availWidth - sWidth) / 2;
                    var t = (screen.availHeight - sHeight) / 2;
                    config += ',left=' + l + ',top=' + t + ',width=' + sWidth + ',height=' + sHeight;
                }
                return window.open(url, title, 'left=' + l + ',top=' + t + ',width=' + sWidth + ',height=' + sHeight);
            }
        }
    });
})(jQuery);

/**
*
* 
*/
window.Authorize = function (url) {
    subWin.close();
    if (url) {
        location.href = url;
    }
}